#include<iostream>
#include<vector>

using namespace std;

class Soulution
{
public:
	vector<int>searchRange(vector<int>& nums, int  target)
	{
		int length = nums.size();
		if (length == 0)return{ -1,-1 };
		else if (length == 1)
		{
			if (nums[0] == target)return{ 0,0 };
			else return{ -1,-1 };
		}
		else
		{
			int left = 0;
			int right =length-1;
			int mid = (left+right)/2;
			
			while (left< right)
			{
				if (nums[mid] < target)left = mid+1;
				else right = mid ;
				mid = (left + right) / 2;
			}
			if (nums[left] != target)return{ -1,-1 };
			int begin = left;
			left = 0; right = length - 1;
			while (left < right)
			{
				if (nums[mid] <= target)left = mid;
				else right = mid - 1;
				mid = (left + right + 1) / 2;
			}
			int end = right;
			return{ begin,end };
		}
	}
};

//int main()
//{
//	vector<int>vec = { 1,2,3,4 };
//	cout << vec.size () << endl;
//	return 0;
//}